package tr.edu.metu.is.mega.common.dto;

import java.util.ArrayList;
import java.util.List;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * Data structure class for courses.
 */
public class CourseDTO extends BaseDTO {

    private static final long serialVersionUID = 70907347892535882L;

    public static final String FIELD_CODE = "code";

    public static final String FIELD_NAME = "name";

    public static final String FIELD_SEMESTER = "semester";

    public static final String FIELD_INSTRUCTOR = "instructor";

    public static final String FIELD_ASSISTANTS = "assistantList";

    public static final String FIELD_INSTRUCTOR_NAME = "instructor.fullName";

    @NotNull
    @Size(max = 10)
    private String code;

    @NotNull
    @Size(max = 30)
    private String name;

    @NotNull
    @Size(max =20)
    private String semester;

    private UserDTO instructor;

    private List<CourseAssistantDTO> assistants;

    private List<ActivityDTO> activities;

    private List<CourseStudentDTO> students;

    private List<TeamDTO> teams;

    /*
     * 
     * 
     * private List<Announcement> announcements;
     * 
     * 
     * 
     * private List<Lecturenote> lecturenotes;
     * 
     * private List<Team> teams;
     */
    /**
     * Default constructor.
     */
    public CourseDTO() {
        teams = new ArrayList<TeamDTO>(1);
    }

    /**
     * Returns code.
     * 
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * Sets code value.
     * 
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Returns name.
     * 
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * Sets name value.
     * 
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Returns semester.
     * 
     * @return the semester
     */
    public String getSemester() {
        return semester;
    }

    /**
     * Sets semester value.
     * 
     * @param semester the semester to set
     */
    public void setSemester(String semester) {
        this.semester = semester;
    }

    /**
     * Returns instructor.
     * 
     * @return the instructor
     */
    public UserDTO getInstructor() {
        return instructor;
    }

    /**
     * Sets instructor value.
     * 
     * @param instructor the instructor to set
     */
    public void setInstructor(UserDTO instructor) {
        this.instructor = instructor;
    }

    /**
     * Returns assistants.
     * 
     * @return the assistants
     */
    public List<CourseAssistantDTO> getAssistants() {
        return assistants;
    }

    /**
     * Sets assistants value.
     * 
     * @param assistants the assistants to set
     */
    public void setAssistants(List<CourseAssistantDTO> assistants) {
        this.assistants = assistants;
    }

    /**
     * Returns comma separated list of assistant names.
     * 
     * @return assistant names
     */
    public String getAssistantList() {
        if (assistants == null || assistants.size() == 0) {
            return "";
        }
        String s = "";
        for (CourseAssistantDTO dto : assistants) {
            s += dto.getUser().getFullName() + ", ";
        }
        return s.substring(0, s.length() - 2);
    }

    /**
     * Returns activities.
     * 
     * @return the activities
     */
    public List<ActivityDTO> getActivities() {
        return activities;
    }

    /**
     * Sets activities value.
     * 
     * @param activities the activities to set
     */
    public void setActivities(List<ActivityDTO> activities) {
        this.activities = activities;
    }

    /**
     * Returns students.
     * 
     * @return the students
     */
    public List<CourseStudentDTO> getStudents() {
        return students;
    }

    /**
     * Sets students value.
     * 
     * @param students the students to set
     */
    public void setStudents(List<CourseStudentDTO> students) {
        this.students = students;
    }

    /**
     * Returns teams.
     * 
     * @return the teams
     */
    public List<TeamDTO> getTeams() {
        return teams;
    }

    /**
     * Sets teams value.
     * 
     * @param teams the teams to set
     */
    public void setTeams(List<TeamDTO> teams) {
        this.teams = teams;
    }

    /**
     * Returns basic course info.
     * 
     * @return basic course info
     */
    public String getBasicInfo() {
        return code + " (" + name + ") / " + semester;
    }

}
